<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:icecore="http://www.icefaces.org/icefaces/core"
	xmlns:ace="http://www.icefaces.org/icefaces/components"
	xmlns:ice="http://www.icesoft.com/icefaces/component">
<f:view locale="#{localeBean.currentLocale}" />
<h:head>
	<title>MOJ</title>
</h:head>
<h:body>
	<ui:composition template="/template/masterTemplate.xhtml">
		<ui:define name="content">
			<h:form prependId="false" id="searchForm">
			<ice:messages/>
			<ace:panel>
				<ice:outputLabel value="#{msgs['drawingdocument.lable.title']}" />
				<ice:panelGrid columns="4" >
					<ice:outputLabel value="#{msgs['realtydocument.lable.realtyNo']}" />
					<ice:inputText id="regNO" value="#{drawingDocumentBean.searchDocument.realtyRegistrationNumber}" />
					<ice:outputLabel value="#{msgs['realtydocument.lable.realtyYear']}" />
					<ice:inputText id="regYear" value="#{drawingDocumentBean.searchDocument.documentYear}"/>
					<h:commandButton value="#{msgs['btn.label.search']}" action="#{drawingDocumentBean.search}" >
						<f:ajax execute="regNO regYear" render="@form"/>
					</h:commandButton>
					<h:commandButton onclick="saveDocDialog.show();" id="addDoc" value="#{msgs['btn.label.add']}" type="button"/>
					<h:commandLink value="#{msgs['btn.label.return']}"  action="/pages/home.xhtml?faces-redirect=true"/>
				</ice:panelGrid>
				</ace:panel>
				  
				<ace:dataTable value="#{drawingDocumentBean.searchResult}" rendered="#{not empty drawingDocumentBean.searchResult}"
						  binding="#{table}"
                          var="item"
                          paginator="true"
                          paginatorPosition="bottom"
                          rows="10"
                          >
                <ace:column headerText="#{msgs['realtydocument.lable.search.delete']}">
                <ace:pushButton action="#{drawingDocumentBean.delete(table.rowIndex)}" value="#{msgs['realtydocument.lable.search.delete']}"  />
             	   
                </ace:column>
                <ace:column headerText="#{msgs['realtydocument.lable.search.show']}">
	               <h:commandButton  action="#{drawingDocumentBean.getViewerUrl(table.rowIndex)}" value="#{msgs['realtydocument.lable.search.show']}">
						<f:ajax render=":searchForm:viewerDialog" onevent="openViewerPopup"/>
					</h:commandButton>
                </ace:column>
                
                <ace:column headerText="#{msgs['realtydocument.lable.search.edit']}">
				<h:commandButton  action="#{drawingDocumentBean.edit(table.rowIndex)}" value="#{msgs['realtydocument.lable.search.edit']}">
					<f:ajax render="@all" onevent="openSaveDocPopup"/>
				</h:commandButton>
               </ace:column>
                <ace:column headerText="#{msgs['realtydocument.lable.realtyNo']}">
                    <h:outputText  value="#{item.realtyRegistrationNumber}"/>
                </ace:column>
                 <ace:column headerText="#{msgs['realtydocument.lable.realtyYear']}" >
                    <h:outputText  value="#{item.documentYear}"/>
                </ace:column>
               
            </ace:dataTable>
			  <ace:dialog id="viewerDialog"
		                     header=""
		                     widgetVar="viewerDialog"
		                     closable="true"
		                     modal="true"
		                     draggable="false"
		                     showEffect="clip"
		                     hideEffect="fade"
		                     width="1300"  
		                     height="400" position="fixed">
		                    
							<iframe src="#{drawingDocumentBean.url}" width="100%" height="90%" scrolling="yes"/>
								
				</ace:dialog>
		</h:form>
		<ace:dialog id="saveDocDialog"
                       header=""
                       widgetVar="saveDocDialog"
                       closable="true"
                       modal="true"
                       draggable="false"
                       showEffect="clip"
                       hideEffect="fade"
                       width="1300"  
                       height="400" position="fixed" >
                      
				<ui:include src="/pages/drawingDoc/drawingDoc.xhtml"/>  						
  		</ace:dialog>
		<script>
		function openViewerPopup(data){
			if (data.status == "complete") {
				viewerDialog.show();
			}
		}
		function openSaveDocPopup(data){
			if (data.status == "complete") {
				saveDocDialog.show();
			}
		}
		</script>
	 	</ui:define>
	</ui:composition>
</h:body>
</html>